// 评论组件
import ajax from '@/utils/request'

// 文章评论接口
export const addComment = (articleId, content) => {
  return ajax({
    method: 'POST',
    url: '/app/v1_0/comments',
    data: {
      target: articleId,
      content
    }
  })
}
// 获取该文章所有评论
export const getComments = (articleId, offset) => {
  return ajax({
    method: 'GET',
    url: '/app/v1_0/comments',
    params: {
      type: 'a',
      source: articleId,
      offset
    }

  })
}
// 对文章进行点赞
export const addCommentLike = (commentId) => {
  return ajax({
    method: 'POST',
    url: '/app/v1_0/comment/likings',
    data: {
      target: commentId
    }
  })
}

// 对文章取消点赞
export const deleteCommentLike = (commentId) => {
  return ajax({
    method: 'DELETE',
    url: '/app/v1_0/comment/likings/' + commentId
  })
}
// 定义回复评论接口
export const getCommentReplys = (replyId, offset) => {
  return ajax({
    method: 'GET',
    url: '/app/v1_0/comments',
    params: {
      type: 'c',
      source: replyId,
      offset
    }
  })
}
// 评论回复
export const addCommentReply = (commentId, articleId, content) => {
  return ajax({
    method: 'POST',
    url: '/app/v1_0/comments',
    data: {
      target: commentId,
      content,
      art_id: articleId
    }
  })
}
